package com.heima.apis.article.fallback;

import com.heima.apis.article.IArticleClient;
import com.heima.common.exception.BusinessException;
import com.heima.model.article.dtos.ArticleCommentDto;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.article.pojos.ApArticleConfig;
import com.heima.model.comment.dtos.CommentConfigDto;
import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.common.vos.PageResultVo;
import com.heima.model.wemedia.dtos.StatisticsDto;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.Map;

/**
 * feign失败配置
 *
 * @author: lin
 * @Since: 2025/6/13
 */
@Component
public class IArticleClientFallback implements IArticleClient {
    @Override
    public ResponseResult<Long> saveArticle(ArticleDto dto) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "获取数据失败");
    }

    @Override
    public ResponseResult<String> markImageAsDeleted(String imgUrl) {
        return ResponseResult.errorResult(
                AppHttpCodeEnum.SERVER_ERROR,
                "删除图片数据失败");
    }

    @Override
    public void delArticleById(Long id) {
        throw new BusinessException(AppHttpCodeEnum.SERVER_ERROR, "删除文章失败");
    }

    @Override
    public ResponseResult<Map<String, Object>> queryLikesAndConllections(Integer id, Date beginDate, Date endDate) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "获取数据失败");
    }

    @Override
    public PageResultVo<ApArticle> newPage(StatisticsDto dto) {
        PageResponseResult<ApArticle> responseResult = new PageResponseResult<>(dto.getPage(), dto.getSize(), 0);
        responseResult.setCode(501);
        responseResult.setErrorMessage("获取数据失败");
        return null;
    }

    @Override
    public ResponseResult<ApArticleConfig> findArticleConfigByArticleId(Long articleId) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "获取数据失败");
    }

    @Override
    public PageResponseResult findNewsComments(ArticleCommentDto dto) {
        PageResponseResult responseResult = new PageResponseResult(dto.getPage(), dto.getSize(), 0);
        responseResult.setCode(501);
        responseResult.setErrorMessage("获取数据失败");
        return responseResult;
    }

    @Override
    public ResponseResult<AppHttpCodeEnum> updateCommentStatus(CommentConfigDto dto) {
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR, "获取数据失败");
    }
}